import request from '../utils/http-utils.js'
const adminApi = {
	Login: '/admin/login',
	Logout: '/user/logout',
	AdminDetail: '/admin/info/',
	AdminOperate: '/admin',
	AdminByPage: '/admin/page',
	AdminOperateWithPermission: '/api/v1/private/admin'
}


/**
 * 管理员登录
 * login func
 * @param {Object} param
 */
export function login(param) {
	return request({
		url: adminApi.Login,
		method: 'post',
		data: param
	})
}

/**
 * 查询管理员信息
 * @param {Object} id
 */
export function getAdminInfo(id) {
	return request({
		url: adminApi.AdminDetail + id,
		method: 'get'
	})
}

/**
 * 添加管理员
 * @param {Object} data
 */
export function addAdmin(data) {
	return request({
		url: adminApi.AdminOperate,
		method: 'post',
		data: data
	})
}

/**
 * 更新管理员
 * @param {Object} data
 */
export function updateAdmin(data) {
	return request({
		url: adminApi.AdminOperate,
		method: 'put',
		data: data
	})
}

/**
 * 删除管理员
 * @param {Object} id
 */
export function deleteAdmin(id) {
	return request({
		url: adminApi.AdminOperate + `/${id}`,
		method: 'delete'
	})
}

/**
 * 分页查询管理员列表
 * @param {Object} page
 */
export function getAdminByPage(page) {
	return request({
		url: adminApi.AdminByPage,
		method: 'post',
		data: page
	})
}
